/**
 *  *2010-5-15 下午11:27:13  add 
 */
package com.base.myproject.client.HR.Self;

import java.util.ArrayList;
import java.util.Date;

import com.base.myproject.client.busi.BaseStore;
import com.base.myproject.client.busi.LasyObejct;
import com.base.myproject.client.busi.BO.BusiObject;
import com.base.myproject.client.jdbc.StoreInfo;
import com.base.myproject.client.ui.BaseFormPanel;
import com.base.myproject.client.ui.celleditor.BaseComboBoxForm;
import com.base.myproject.client.ui.celleditor.BaseComboBoxX;
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.Style.VerticalAlignment;
import com.extjs.gxt.ui.client.data.BaseModelData;
import com.extjs.gxt.ui.client.data.ModelType;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.VerticalPanel;
import com.extjs.gxt.ui.client.widget.form.DateField;
import com.extjs.gxt.ui.client.widget.form.FieldSet;
import com.extjs.gxt.ui.client.widget.form.NumberField;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.layout.TableData;
import com.extjs.gxt.ui.client.widget.layout.TableLayout;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;

/**
 * 人力资源的雇用工作
 * 
 * @author Administrator 2010-5-15 javazgw@gmail.com
 */
public class SelfBcode_Employment extends LayoutContainer implements LasyObejct {

	BaseStore<BusiObject> mainstore = null;
	DateField C_data9 = null;
	static  String W_date="";//类变量  用来保存入职日期  其他页面会用到处理问题
	public SelfBcode_Employment(BaseStore<BusiObject> mainstore) {
		this.mainstore = mainstore;
		init();
		//this.setStyleAttribute("background-color", "#DFE8F6");
	}
	
	public SelfBcode_Employment() {
	}

	void init() {
		
		initwidget();

	}

	Widget initwidget() {

		FieldSet fs1 = new FieldSet();
		fs1.setHeading("部门");
		//fs1.setStyleName("firldset_css1");
		fs1.add(create_bcode_Form());
		fs1.setHeight(60);
		
		FieldSet fs2 = new FieldSet();
		fs2.add(createForm());
		//fs2.setStyleName("firldset_css1");
		fs2.setHeading("工作");
		fs2.setHeight(240);
		
		
		VerticalPanel v = new VerticalPanel();
		v.setSpacing(2);
		v.add(fs1);
		v.add(fs2);
		v.setHeight(420);
		this.add(v);
		return null;
	}

	BaseStore<BusiObject> store = null;

	public BaseStore<BusiObject> getStore() {
		if (store == null) {
			createStore();
		}
		return store;
	}

	BaseStore<BusiObject> createStore() {
		ModelType type = new ModelType();
		type.setRoot("records");
		type.setRecordName("record");
		type.setTotalName("totle");
		type.addField("icode");
		type.getField("icode").setType(Long.class);
		type.addField("bcode");
		type.getField("bcode").setType(String.class);
		type.addField("employno");
		type.getField("employno").setType(String.class);
		type.addField("employstartdate");
		type.getField("employstartdate").setType(Date.class);
		type.addField("employlevel");
		type.getField("employlevel").setType(String.class);
		type.addField("employinnertitle");
		type.getField("employinnertitle").setType(String.class);
		type.addField("employoutertitle");
		type.getField("employoutertitle").setType(String.class);
		type.addField("employstatus");
		type.getField("employstatus").setType(String.class);
		type.addField("entrydate");
		type.getField("entrydate").setType(Date.class);
		type.addField("Regularizationdate");
		type.getField("Regularizationdate").setType(Date.class);
		type.addField("groupregularizationdate");
		type.getField("groupregularizationdate").setType(Date.class);
		type.addField("lastjobdate");
		type.getField("lastjobdate").setType(Date.class);
		type.addField("lastpaydate");
		type.getField("lastpaydate").setType(Date.class);
		type.addField("Resignationdate");
		type.getField("Resignationdate").setType(Date.class);
		type.addField("Insurancedate");
		type.getField("Insurancedate").setType(Date.class);
		type.addField("contractstartdate");
		type.getField("contractstartdate").setType(Date.class);
		type.addField("contractsenddate");
		type.getField("contractsenddate").setType(Date.class);
		type.addField("jobproperty");
		type.getField("jobproperty").setType(String.class);
		type.addField("jobgroup");
		type.getField("jobgroup").setType(String.class);
		type.addField("jobtype");
		type.getField("jobtype").setType(String.class);
		type.addField("paymethod");
		type.getField("paymethod").setType(String.class);
		type.addField("Vacation");
		type.getField("Vacation").setType(String.class);
		type.addField("boss");
		type.getField("boss").setType(String.class);
		type.addField("lockersno");
		type.getField("lockersno").setType(String.class);
		type.addField("hostelno");
		type.getField("hostelno").setType(String.class);
		type.addField("attendancecardno");
		type.getField("attendancecardno").setType(String.class);
		type.addField("Work_experience");
		type.getField("Work_experience").setType(Double.class);
		
		StoreInfo info = new StoreInfo();
		info.setTablename("bcode_job");
		info.setKeyname(new String[] { "icode" });
		info
				.setSql("select icode,bcode,employno,employstartdate,employlevel,employinnertitle,"
						+ "employoutertitle,employstatus,entrydate,Regularizationdate,groupregularizationdate,"
						+ "lastjobdate,lastpaydate,Resignationdate,Insurancedate,contractstartdate,contractsenddate,"
						+ "jobproperty,jobgroup,jobtype,paymethod,Work_experience,Vacation,boss,(select top 1 name from hr_wardrobe where exists (select  * from hr_wardrode_bcode  where hr_wardrode_bcode.bcode = bcode_job.bcode  and hr_wardrode_bcode.upcode = hr_wardrobe.code ) ) as lockersno,(select top 1 code from hr_hostel_bcode where hr_hostel_bcode.bcode =  bcode_job.bcode ) as hostelno,attendancecardno from bcode_job where bcode='{bcode}'");
		info.setParent(mainstore);// 关联主表
		info.setLinkparentcolumns(new String[] { "bcode" }); // 关联主表字段
		info.setLinkparent_chile_columns(new String[] { "bcode" });// 关联主表字段
		store = new BaseStore<BusiObject>(type, info);
		return store; 
	}
	BaseFormPanel form = null;
	BaseFormPanel createForm() {
		BaseFormPanel form = new BaseFormPanel(getStore());
		form.setBodyBorder(false);
		form.setPadding(6);
		form.setStyleName("form_css2");
		TableLayout tl = new TableLayout(8);

		TableData td = new TableData();
		td.setRowspan(1);
		td.setHorizontalAlign(HorizontalAlignment.LEFT);
		td.setVerticalAlign(VerticalAlignment.TOP);
		td.setPadding(2);
		form.setLayout(tl);
		form.setHeaderVisible(false);

		form.add(new Label("雇佣编号:"), td);
		TextField<String> C_num3 = new TextField<String>();
		C_num3.setReadOnly(true);
		C_num3.setName("employno");
		form.add(C_num3, td);
		
		form.add(new Label("雇佣日期:"), td);
		DateField C_data4 = new DateField();
		C_data4.getPropertyEditor().setFormat(
				DateTimeFormat.getFormat("yyyy-MM-dd"));
		C_data4.setReadOnly(true);
		C_data4.setWidth(127);
		C_data4.setName("employstartdate");
		form.add(C_data4, td);
		
		form.add(new Label("雇佣级别:"), td);
		TextField<String> C_num5 = new TextField<String>();
		C_num5.setReadOnly(true);
		C_num5.setName("employlevel");
		form.add(C_num5, td);
		
		form.add(new Label("集团入职日期:"), td);
		DateField C_data11 = new DateField();
		C_data11.getPropertyEditor().setFormat(
				DateTimeFormat.getFormat("yyyy-MM-dd"));
		C_data11.setReadOnly(true);
		C_data11.setWidth(127);
		C_data11.setName("groupregularizationdate");
		form.add(C_data11, td);
		
		
		form.add(new Label("内部职位:"), td);
		TextField<String> in_work = new TextField<String>();
		in_work.setReadOnly(true);
		in_work.setName("employoutertitle");
		form.add(in_work, td);
		
		form.add(new Label("外部职位:"), td);
		TextField<String> C_num7 = new TextField<String>();
		C_num7.setReadOnly(true);
		C_num7.setName("employinnertitle");//内部职位与外部职位互换
		form.add(C_num7, td);
		
		form.add(new Label("雇佣状态:"), td);
		TextField<String> C_num8 = new TextField<String>();
		C_num8.setReadOnly(true);
		C_num8.setName("employstatus");
		form.add(C_num8, td);
		
		form.add(new Label("考勤卡编码:"), td);
		TextField<String> C_num26 = new TextField<String>();
		C_num26.setReadOnly(true);
		C_num26.setName("attendancecardno");
		form.add(C_num26, td);
		
		form.add(new Label("入职日期:"), td);
		C_data9 = new DateField();
		C_data9.getPropertyEditor().setFormat(
				DateTimeFormat.getFormat("yyyy-MM-d"));
		C_data9.setReadOnly(true);
		C_data9.setWidth(127);
		C_data9.setName("entrydate");
		form.add(C_data9, td);
		
		form.add(new Label("转正日期:"), td);
		DateField C_data10 = new DateField();
		C_data10.getPropertyEditor().setFormat(
				DateTimeFormat.getFormat("yyyy-MM-dd"));
		C_data10.setReadOnly(true);
		C_data10.setWidth(127);
		C_data10.setName("Regularizationdate");
		form.add(C_data10, td);
		
		form.add(new Label("工作年限:"), td);
		NumberField score = new NumberField();
		score.setReadOnly(true);
		score.setName("Work_experience");
		form.add(score, td);
		
		form.add(new Label("最后工作日期:"), td);
		DateField C_data12 = new DateField();
		C_data12.getPropertyEditor().setFormat(
				DateTimeFormat.getFormat("yyyy-MM-dd"));
		C_data12.setWidth(127);
		C_data12.setReadOnly(true);
		C_data12.setName("lastjobdate");
		form.add(C_data12, td);
		
		form.add(new Label("工作性质:"), td);
		TextField<String> C_num18 = new TextField<String>();
		C_num18.setReadOnly(true);
		C_num18.setName("jobproperty");
		form.add(C_num18, td);
		
		form.add(new Label("工作组别:"), td);
		TextField<String> C_num19 = new TextField<String>();
		C_num19.setReadOnly(true);
		C_num19.setName("jobgroup");
		form.add(C_num19, td);
		
		form.add(new Label("工作类别:"), td);
		TextField<String> C_num20 = new TextField<String>();
		C_num20.setReadOnly(true);
		C_num20.setName("jobtype");
		form.add(C_num20, td);
		
		form.add(new Label("辞职有效日期:"), td);
		DateField C_data14 = new DateField();
		C_data14.getPropertyEditor().setFormat(
				DateTimeFormat.getFormat("yyyy-MM-dd"));
		C_data14.setWidth(127);
		C_data14.setReadOnly(true);
		C_data14.setName("Resignationdate");
		form.add(C_data14, td);
		
		form.add(new Label("宿舍编号:"), td);
		TextField<String> C_num225 = new TextField<String>();
		C_num225.setReadOnly(true);
		C_num225.setName("hostelno");
		form.add(C_num225, td);
		
		form.add(new Label("假期:"), td);
		TextField<String> C_num22 = new TextField<String>();
		C_num22.setReadOnly(true);
		C_num22.setName("Vacation");
		form.add(C_num22, td);
		
		form.add(new Label("上司:"), td);
		TextField<String> C_num23 = new TextField<String>();
		C_num23.setReadOnly(true);
		C_num23.setName("boss");
		form.add(C_num23, td);
		
		form.add(new Label("储物柜编号:"), td);
		TextField<String> C_num24 = new TextField<String>();
		C_num24.setReadOnly(true);
		C_num24.setName("lockersno");
		form.add(C_num24, td);

		form.inited();
		return form;
	}

	BaseFormPanel create_bcode_Form() {
		BaseFormPanel form = new BaseFormPanel(mainstore);
		form.setBodyBorder(false);
		form.setPadding(6);
		form.setStyleName("form_css2");
		TableLayout tl = new TableLayout(8);

		TableData td = new TableData();
		td.setRowspan(1);
		td.setHorizontalAlign(HorizontalAlignment.LEFT);
		td.setVerticalAlign(VerticalAlignment.TOP);
		td.setPadding(2);
		form.setLayout(tl);
		form.setHeaderVisible(false);
		
		//where name is not null and id is not null and len(id)=(select max(len(id)) from systeminfo)
		form.add(new Label("分部门:  "), td);
		TextField<String> C_num27= new TextField<String>();
		C_num27.setReadOnly(true);
		C_num27.setName("systemid");
		form.add(C_num27, td);
		
		form.add(new Label("部门:  "), td);
		TextField<String> C_dep = new TextField<String>();
		C_dep.setReadOnly(true);
		C_dep.setName("up_department");
		form.add(C_dep, td);

		form.add(new Label("识别码:  "), td);
		TextField<String> C_num25 = new TextField<String>();
		C_num25.setReadOnly(true);
		C_num25.setName("Identifier");
		form.add(C_num25, td);
		
		form.add(new Label("角色:  "), td);
		TextField<String>C_num26 = new TextField<String>();
		C_num26.setName("groupicode");
		C_num26.setReadOnly(true);
		form.add(C_num26, td);
		
		form.inited();
		return form;
	}

	@Override
	public boolean isopen() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean open() {
		// TODO Auto-generated method stub
		return false;
	}
	public void set_w_date() {
		W_date=C_data9.getRawValue();
	}
	public String get_w_date() {
		return W_date;
	}
	
}
